from collections import deque

n, L = map(int, input().split())
nums = list(map(int, input().split()))
inf = float('inf')
dp = [inf] * (L + 1)
dp[1] = 0
queue = deque([1])
while queue:
    curr = queue.popleft()
    if curr == L:
        break
    for x in nums:
        for y in nums:
            next_pos = (curr + x + y - 1) % L + 1
            if not next_pos: continue
            if dp[next_pos] >= dp[curr] + 1:
                dp[next_pos] = dp[curr] + 1
                queue.append(next_pos)
if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])
